package com.xsir.ditan.common.config;

import com.xsir.ditan.admin.constant.UserConstant;
import org.springframework.context.annotation.Configuration;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author user
 * @date 2021/2/7
 */
@Configuration
public class ThymeleafConfig {
    @Resource(name="thymeleafViewResolver")
    private void configureThymeleafStaticVars(ThymeleafViewResolver viewResolver) {
        if(viewResolver == null) {
            return;
        }
        Map<String, Object> vars = new HashMap<>(4);
        vars.put("USER_GENDER_LIST", UserConstant.GENDER);
        vars.put("USER_STATUS_LIST", UserConstant.STATUS);
        viewResolver.setStaticVariables(vars);
    }
}
